env = Environment()

assert not env.Execute( './glib.sh' )

env.Append( CPPPATH = [ '#', '.glib/include/glib-2.0', '.glib/lib/glib-2.0/include' ] )
env.Append( CPPFLAGS = [ '-g', '-Wall', '-Werror', '-Wl,--export-dynamic' ] )
env.Append( LIBPATH = [ '.glib/lib' ] )
env.Append( LIBS = [ 'glib-2.0', 'gmodule-2.0' ] )
env.Append( RPATH = [ env.Dir( '#' ).abspath, env.Dir( '.glib/lib' ).abspath ] )

lib_fhe = env.SharedLibrary( 'fhe', env.Glob( 'fhe/*.c' ) )

env = env.Clone()
env.Append( LIBS = [ lib_fhe ] )

test_common = env.SharedLibrary( 'test_common', env.Glob( 'test/common/*.c' ) )

env = env.Clone()
env.Append( LIBS = [ test_common, 'gtest' ] )

test_srcs = env.Glob( 'test/*.cpp' )
for test_src in test_srcs:
    test_exe = env.Program( test_src )
    test_name = str( test_exe[0] )
    env.Command( test_name + '.out', test_exe, test_name )
